﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;

namespace LibraryManagement
{
    public partial class BookListForm : Form
    {
        private Form parentForm;
        public BookListForm(Form parent)
        {
            InitializeComponent();
            parentForm = parent;
            LoadBooks();
        }
        private void LoadBooks()
        {
            string query = "SELECT * FROM Books";
            DataTable dt = DatabaseHelper.ExecuteQuery(query);
            dgvBooks.DataSource = dt;
        }
        private void btnBack_Click_1(object sender, EventArgs e)
        {
            parentForm.Show();
            this.Close();
        }

        //public int? GetSelectedBookId()
        //{
        //    if (dgvBooks.SelectedRows.Count > 0)
        //    {
        //        return (int?)dgvBooks.SelectedRows[0].Cells["BookID"].Value;
        //    }
        //    return null;
        //}

    }
}
